package com.cloudwebrtc.voip.mediaengine.impl;

import com.cloudwebrtc.voip.mediaengine.AudioStream;
import com.cloudwebrtc.voip.mediaengine.DataStream;
import com.cloudwebrtc.voip.mediaengine.MediaStream;
import com.cloudwebrtc.voip.mediaengine.StreamType;
import com.cloudwebrtc.voip.mediaengine.VideoStream;

public class MediaStreamImpl implements MediaStream {
	//implement for MediaStream_JNI.cpp
	private long nativePtr = 0;
	private native long GetAudioStream(long nativePtr);
	private native long GetVideoStream(long nativePtr);
	private native long GetDataStream(long nativePtr);
	private native int StartStreamSending(long nativePtr,int type, boolean restart);
	private native boolean StreamIsSending(long nativePtr,int type);
	private native int StopStreamSending(long nativePtr,int type);
	
	private native int StartStreamReceiving(long nativePtr,int type, boolean restart);
	private native boolean StreamIsReceiving(long nativePtr,int type);
	private native int StopStreamReceiving(long nativePtr,int type);
	
	public MediaStreamImpl(long aNativePtr)
	{
		nativePtr = aNativePtr;
	}
		
	@Override
	public VideoStream GetVideoStream() {
		return new VideoStreamImpl(GetVideoStream(nativePtr));
	}

	@Override
	public AudioStream GetAudioStream() {
		return new AudioStreamImpl(GetAudioStream(nativePtr));
	}

	@Override
	public DataStream GetDataStream() {
		return new DataStreamImpl(GetDataStream(nativePtr));
	}

	@Override
	public int StartStreamSending(StreamType type, boolean restart) {
		return StartStreamSending(nativePtr,type.IntgerValue(),restart);
	}

	@Override
	public boolean StreamIsSending(StreamType type) {
		return StreamIsSending(nativePtr,type.IntgerValue());
	}

	@Override
	public int StopStreamSending(StreamType type) {
		return StopStreamSending(nativePtr,type.IntgerValue());
	}

	@Override
	public int StartStreamReceiving(StreamType type, boolean restart) {
		return StartStreamReceiving(nativePtr,type.IntgerValue(),restart);
	}

	@Override
	public boolean StreamIsReceiving(StreamType type) {
		return StreamIsReceiving(nativePtr,type.IntgerValue());
	}

	@Override
	public int StopStreamReceiving(StreamType type) {
		return StopStreamReceiving(nativePtr,type.IntgerValue());
	}
}
